package com.bawei.mall.user.contorller;

import com.bawei.common.core.domain.R;
import com.bawei.mall.product.domain.model.MallUserFollow;
import com.bawei.mall.product.domain.model.UserFollowList;
import com.bawei.mall.user.service.MallUserFollowService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：张余庆
 * @Package：com.bawei.mall.user.contorller
 * @Project：mall_cloud
 * @name：MallUserFollowContorller
 * @Date：2024/7/4 19:47
 */
@RestController
@RequestMapping("follow")
public class MallUserFollowContorller {

    @Autowired
    private MallUserFollowService service;

    /**
     * 功能：查询用户关注表
     * @return
     */
    @GetMapping("list")
    @ApiOperation("查询用户关注表")
    public R<UserFollowList> list(@RequestParam(value = "pageNum") Integer pageNum,
                                           @RequestParam(value = "pageSize") Integer pageSize){
        UserFollowList list = service.list(pageNum,pageSize);
        return R.ok(list);
    }

    /**
     * 功能：清空用户关注
     * @return
     */
    @PostMapping("clear")
    @ApiOperation("清空用户关注")
    public R clear(){
        service.clear();
        return R.ok();
    }

    /**
     * 功能：添加用户关注表
     * @param mallUserFollow
     * @return
     */
    @PostMapping("add")
    @ApiOperation(value = "添加用户关注表")
    public R add(@RequestBody MallUserFollow mallUserFollow){
        service.add(mallUserFollow);
        return R.ok();
    }
}
